package com.wisedu.w5autocode.template;

import com.wisedu.w5autocode.views.*;

public class PortletConfigTemplate
{
  protected static String nl;
  public static synchronized PortletConfigTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    PortletConfigTemplate result = new PortletConfigTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<beans xmlns=\"http://www.springframework.org/schema/beans\"" + NL + "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + NL + "\txsi:schemaLocation=\"http://www.springframework.org/schema/beans " + NL + "\thttp://www.springframework.org/schema/beans/spring-beans.xsd\">" + NL + "" + NL + "\t<bean id=\"propertyConfigurer\" class=\"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer\">" + NL + "        <property name=\"locations\">" + NL + "            <list>" + NL + "                <value>classpath:environment.properties</value>" + NL + "                <value>classpath:environmentOverride.properties</value>" + NL + "            </list>" + NL + "        </property>" + NL + "        <property name=\"fileEncoding\" value=\"GBK\"/>" + NL + "        <property name=\"ignoreResourceNotFound\" value=\"true\"/>" + NL + "\t</bean>    " + NL + "\t" + NL + "\t<!-- handle Mapping -->" + NL + "\t<bean id=\"portletModeParameterHandlerMapping\"" + NL + "\t\tclass=\"org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping\">" + NL + "\t\t<property name=\"order\" value=\"10\" />" + NL + "\t\t<property name=\"interceptors\">" + NL + "\t\t\t<list>" + NL + "\t\t\t\t<ref bean=\"parameterMappingInterceptor\" />" + NL + "\t\t\t\t<ref bean=\"paginationContextHandlerInterceptor\" />" + NL + "\t\t\t\t<ref bean=\"portletEntityInterceptor\" />" + NL + "\t\t\t</list>" + NL + "\t\t</property>" + NL + "\t\t<property name=\"portletModeParameterMap\">" + NL + "\t\t\t<map>" + NL + "\t\t\t\t<entry key=\"view\">" + NL + "\t\t\t\t\t<map>" + NL + "\t\t\t\t\t\t<entry key=\"query\">" + NL + "\t\t\t\t\t\t\t<ref bean=\"";
  protected final String TEXT_2 = "\" />" + NL + "\t\t\t\t\t\t</entry>" + NL + "\t\t\t\t\t\t<entry key=\"identityValidate\">" + NL + "\t\t\t\t\t\t\t<ref bean=\"identityValidateController\" />" + NL + "\t\t\t\t\t\t</entry>" + NL + "\t\t\t\t\t\t<entry key=\"optionsRetrieve\">" + NL + "\t\t\t\t\t\t\t<ref bean=\"optionsRetrieveController\" />" + NL + "\t\t\t\t\t\t</entry>" + NL + "\t\t\t\t\t</map>" + NL + "\t\t\t\t</entry>" + NL + "\t\t\t</map>" + NL + "\t\t</property>" + NL + "\t</bean>" + NL + "" + NL + "\t<bean id=\"portletModeHandlerMapping\"" + NL + "\t\tclass=\"org.springframework.web.portlet.handler.PortletModeHandlerMapping\">" + NL + "\t\t<property name=\"order\" value=\"20\" />" + NL + "\t\t<property name=\"interceptors\">" + NL + "\t\t\t<list>" + NL + "\t\t\t\t<ref bean=\"parameterMappingInterceptor\" />" + NL + "\t\t\t\t<ref bean=\"paginationContextHandlerInterceptor\" />" + NL + "\t\t\t\t<ref bean=\"portletEntityInterceptor\" />" + NL + "\t\t\t</list>" + NL + "\t\t</property>" + NL + "\t\t<property name=\"portletModeMap\">" + NL + "\t\t\t<map>" + NL + "\t\t\t\t<entry key=\"view\" value-ref=\"";
  protected final String TEXT_3 = "\" />" + NL + "\t\t\t</map>" + NL + "\t\t</property>" + NL + "\t</bean>" + NL + "" + NL + "\t<bean id=\"";
  protected final String TEXT_4 = "\" class=\"";
  protected final String TEXT_5 = "\" parent=\"entityQueryController\">" + NL + "\t\t<property name=\"viewName\" value=\"";
  protected final String TEXT_6 = "\" />" + NL + "\t\t<property name=\"entityClassName\" value=\"";
  protected final String TEXT_7 = "\" />" + NL + "\t</bean>" + NL + "\t" + NL + "\t<bean id=\"defaultExceptionHandler\" parent=\"defaultExceptionHandlerTemplate\" />" + NL + "</beans>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
	PortletConfigArgs args = (PortletConfigArgs)argument;
	

    stringBuffer.append(TEXT_1);
    stringBuffer.append(args.getViewControllerName());
    stringBuffer.append(TEXT_2);
    stringBuffer.append(args.getViewControllerName());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(args.getViewControllerName());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(args.getViewControllerClass());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(args.getJspName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(args.getMem().getEntityPackageName() );
    stringBuffer.append(TEXT_7);
    return stringBuffer.toString();
  }
}
